package com.machine.action.search;

import javax.annotation.Resource;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.machine.bean.Componentpart;
import com.machine.bean.User;
import com.machine.dao.user.ComponentDao;
import com.machine.dao.user.UserDao;
import com.opensymphony.xwork2.ActionSupport;

@Component("searchComDel")
@Scope(value = "prototype")
public class SearchComDel extends ActionSupport {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	private Componentpart componentpart;
	private UserDao userDao;

	private User provider;

	public UserDao getUserDao() {
		return userDao;
	}

	@Resource
	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	public User getProvider() {
		return provider;
	}

	public void setProvider(User provider) {
		this.provider = provider;
	}

	public Componentpart getComponentpart() {
		return componentpart;
	}

	public void setComponentpart(Componentpart componentpart) {
		this.componentpart = componentpart;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	private ComponentDao componentDao;

	public ComponentDao getComponentDao() {
		return componentDao;
	}

	@Resource
	public void setComponentDao(ComponentDao componentDao) {
		this.componentDao = componentDao;
	}

	@Override
	public String execute() throws Exception {
		componentpart = componentDao.findById(id);
		if(componentpart != null){
			provider = userDao.getUserById(componentpart.getProviderid());
			System.out.println("provider name : " + provider.getUsername());
		}
		return super.execute();
	}
}
